//
//  ViewController.m
//  协议传值<带返回值.
//
//  Created by dllo on 16/8/4.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ViewController.h"
#import "NextViewController.h"

@interface ViewController ()<NextViewControllerDelegate>
@property (nonatomic, strong) UILabel *label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(200, 200, 200, 50);
    button.backgroundColor = [UIColor grayColor];
    [button setTitle:@"今天真是个好日子" forState:0];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(200, 400, 300, 50)];
    _label.backgroundColor = [UIColor grayColor];
    _label.textColor = [UIColor blackColor];
    _label.text = @"我是VC";
    [self.view addSubview:_label];
}
- (void)buttonAction:(UIButton *)btn {
    NextViewController *nextVC = [[NextViewController alloc] init];
    nextVC.delegate = self;
    CATransition *animation = [CATransition animation];
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.duration = 2;
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromTop;
    [self.view.window.layer addAnimation:animation forKey:@"bb"];
    [self presentViewController:nextVC animated:NO completion:^{
        
        
    }];
}
- (NSString *)weHaveGoodTime:(NSString *)labelText {
    NSString *str = [labelText stringByAppendingString:@",Next参数来了,"];
    _label.text = str; // 反面传值
    return _label.text;// 正面传值
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
